package com.server.web.controller.pinggu;

import com.server.common.annotation.Log;
import com.server.common.core.controller.BaseController;
import com.server.common.core.domain.AjaxResult;
import com.server.common.core.page.TableDataInfo;
import com.server.common.enums.BusinessType;
import com.server.common.utils.poi.ExcelUtil;
import com.server.pinggu.domain.SenActionlog;
import com.server.pinggu.service.ISenActionlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ltao
 * @date 2022-10-23
 */
@RestController
@RequestMapping("/sen/actionlog")
public class SenActionlogController extends BaseController
{
    @Autowired
    private ISenActionlogService senActionlogService;

    /**
     * 查询【请填写功能名称】列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SenActionlog senActionlog)
    {
        List<SenActionlog> list = senActionlogService.queryList(senActionlog);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SenActionlog senActionlog)
    {
        List<SenActionlog> list = senActionlogService.queryList(senActionlog);
        ExcelUtil<SenActionlog> util = new ExcelUtil<SenActionlog>(SenActionlog.class);
        return util.exportExcel(list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(senActionlogService.getById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SenActionlog senActionlog)
    {
        return toAjax(senActionlogService.save(senActionlog));
    }

    /**
     * 修改【请填写功能名称】
     */
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SenActionlog senActionlog)
    {
        return toAjax(senActionlogService.updateById(senActionlog));
    }

    /**
     * 删除【请填写功能名称】
     */
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(senActionlogService.removeByIds(Arrays.asList(ids)));
    }
}
